package com.hqyj.system.service.impl;

import com.hqyj.system.mapper.PermissionMapper;
import com.hqyj.system.model.Permission;
import com.hqyj.system.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cz
 * 2021/9/2 11:58
 */
@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public List<Permission> queryAllPermission() {
        return permissionMapper.queryAllPermission();
    }

    @Override
    public int addPermissionByPermission(Permission permission) {
        return permissionMapper.insertSelective(permission);
    }

    @Override
    public int deletePermissionByPermissionId(int permissionId) {
        return permissionMapper.deleteByPrimaryKey(permissionId);
    }

    @Override
    public int updatePermissionByPermission(Permission permission) {
        return permissionMapper.updateByPrimaryKeySelective(permission);
    }

    @Override
    public Permission queryPermissionByPermissionId(int permissionId) {
        return permissionMapper.selectByPrimaryKey(permissionId);
    }

    @Override
    public List<Permission> queryPermissionByRoleId(int roleId) {
        return permissionMapper.queryPermissionByRoleId(roleId);
    }

    @Override
    public List<Permission> queryPermissionByUserIdAndType(int userId) {
        return permissionMapper.queryPermissionByUserIdAndType(userId);
    }

    @Override
    public List<Permission> queryPermissionBypIdAndType(int pId) {
        return permissionMapper.queryPermissionBypIdAndType(pId);
    }

    @Override
    public List<Permission> queryloginUserPermission(int userId) {
        return permissionMapper.queryloginUserPermission(userId);
    }


}
